package com.xintonghua.hongyi.ui.user;

import android.os.Bundle;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.xintonghua.base.ui.BaseActivity;
import com.xintonghua.base.ui.MySubscriber;
import com.xintonghua.base.utils.MyUtils;
import com.xintonghua.base.utils.RefreshUtils;
import com.xintonghua.hongyi.R;
import com.xintonghua.hongyi.adapter.ClubCardAdapter;
import com.xintonghua.hongyi.bean.ClubCardBean;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

import butterknife.BindView;
import butterknife.ButterKnife;
import io.reactivex.Flowable;
import io.reactivex.android.schedulers.AndroidSchedulers;

public class ClubCardActivity extends BaseActivity implements XRecyclerView.LoadingListener{

    @BindView(R.id.recycler_club_card)
    XRecyclerView recyclerClubCard;
    private ClubCardAdapter adapter;
    private List<ClubCardBean> list = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_club_card);
        ButterKnife.bind(this);
        onSimpleActionBar();
        setSimpleActionBar("会员卡");
        initUI();
    }

    @Override
    public void initUI() {
        super.initUI();
        RefreshUtils.initList(this,recyclerClubCard);
        recyclerClubCard.setLoadingMoreEnabled(false);
        adapter = new ClubCardAdapter(this, list);
        recyclerClubCard.setAdapter(adapter);
        recyclerClubCard.setLoadingListener(this);
    }

    @Override
    public void onRefresh() {
        Flowable.timer(300, TimeUnit.MILLISECONDS).observeOn(AndroidSchedulers.mainThread()).subscribe(new MySubscriber<Long>() {
            @Override
            public void next(Long aLong) {
                adapter.notifyDataSetChanged();
                recyclerClubCard.refreshComplete();
            }
        });
    }

    @Override
    public void onLoadMore() {

    }
}
